In response to the development of multi-core central processing unit (CPU) technologies, the use of processors in which several CPU cores are mounted in one chip is increasing. As a scheme for maintaining the coherence of data that is processed across several CPUs, the functionality of protection for a critical section using multithreading, locking, and the like is provided at the level of the operating system (OS). However, with only this scheme, many difficulties occur and high expenses are incurred when developing and maintaining massive systems.
In addition, there is a method in which a distributed system performs interaction between objects using only a message for the purpose of concurrent execution. However, this method may result in a performance degradation due to the overhead of delivering the message, and may result in deadlock while waiting for a response to the transmitted message.
In the related art, a method for concurrent computation in a distributed system or a multithreaded system involves an actor system. The actor system is a system that is regarded as a basic element of concurrent computation.
An actor can receive and process a message, perform computation and make a decision by itself, create another actor, or transmit a message to another actor.
In the actor system, each actor has its states, i.e. data, and its own processing units for processing the data, e.g., threads. Each actor interacts with other actors while asynchronously exchanging messages with other actors.
The actor can execute operations on a received message, including 1) changing its own state (data), 2) transmitting the message to another actor, 3) creating a new actor, or 4) moving to another host.
The actor system may use synchronous messaging. Synchronous messaging is a messaging scheme in which, after a response to the message that was transmitted has been received, the subsequent operation based on the response is processed.
Synchronous messaging is a scheme that is widely used in server/client systems, including distributed systems. All direct calls in a common application system may be considered synchronous messages.
When such synchronous messages are generally allowed without restrictions, a deadlock may occur, in which two actors wait for a long time while requesting a response to their own read message from each other, without executing other processes. In this deadlock situation, a serious problem in which the entire system stops may occur.
FIG. 1 is a signal flow diagram depicting a method for processing data by transmitting and receiving synchronous messages in an actor system of the related art.
At step S10, a first actor 10 calculates an element a1 for data processing, and requests another element b1, which is required for the data processing. At step S15, the first actor 10 searches for a second actor 20, from which the first actor 10 will request the element b1, and generates a first read message, with which the element b1 will be requested from the second actor 20. The first read message generated by the first actor 10 is a synchronous message, with which, after a response to the message that is transmitted has been received, the subsequent procedure based on the response is processed.
At step S20, the first actor 10 transmits the first read message to the second actor 20.
At step S25, the first actor 10 sets a response standby state corresponding to the transmission of the first read message to the second actor 20. Since the read message is a synchronous message, the first actor 10 can execute subsequent procedures after receiving a response to the first read message from the second actor 20.
Therefore, the first actor 10 sets the state thereof to the response standby state until it receives the response to the first message that was transmitted to the second actor 20.
At step S30, the second actor 20 stores the first read message received from the first actor 10 in a message queue.
At step S35, the second actor 20 transmits a second read message to the first actor 10 in order to acquire information on the state of the first actor 10. Here, the second read message is a message that is not relevant to the first read message.
At step S40, the second actor 20 sets a response standby state corresponding to the transmission of the second read message to the first actor 10. The second actor 20 can execute subsequent procedures after receiving a response to the second read message from the first actor 10.
Therefore, the first actor 10 and the second actor 20 are set to the standby state until they have received respective responses from each other, and thus cannot process other messages.
Consequently, the first actor 10 cannot transmit the response to the second read message to the second actor 20, and the second actor 20 cannot transmit the response to the first read message to the first actor 10.
As a result, the first and second actors 10 and 20 wait indefinitely, and thus a deadlock occurs between the first and second actors 10 and 20.
As described above, the actor system of the related art has the problem in that a deadlock occurs due to the response standby state following the transmission of a synchronous read message.